//#region 
  //#region 变量赋值
  let key = false

  let flag = 0//游戏时期
  let level = 1//游戏等级
  let barrier = 0//游戏关卡数
  let character = ''//角色职业名字
  let ex = 0
  let coins = 0
  let potion_v = 40
  let potion_n = 1
  let max_potion_n = 1
  let max_potion2_n = 1
  let potion2_v = 30
  let potion2_n = 1
  //攻击力，法术强度，速度，暴击率，暴击伤害，防御力
  let atk,spell_power,speed,crit_rate,crit_dmg,defense,jingzhan,yuancheng,fashu,fire,water,wind
  //近战、远程、法术、火伤、水伤、风伤加成
  let m_jingzhan=0
  let m_yuancheng=0
  let m_fashu=0
  let m_fire=0
  let m_water=0
  let m_wind=0

  let w_m_jingzhan=0
  let w_m_yuancheng=0
  let w_m_fashu=0
  let w_m_fire=0
  let w_m_water=0
  let w_m_wind=0
  //武器图片路径
  let wea_src='./img/null.png'
  //装备图片路径
  let equ_src1='./img/null.png'
  let equ_src2='./img/null.png'
  //道具数量初始号
  let pro_list = ''
  //武器详情
  let wea_title = '暂无武器'
  let wea_text1 = ''
  let wea_text2 = ''
  let wea_text3 = ''
  //装备详情1
  let equ_title1 = '暂无胸甲'
  let equ_text1_1 = ''
  let equ_text2_1 = ''
  //装备详情2
  let equ_title2 = '暂无腿甲'
  let equ_text1_2 = ''
  let equ_text2_2 = ''
  //道具详情
  let pro_title = ''
  let pro_text = ''

  let HP = 120
  let maxHP=120
  let MP = 30
  let maxMP = 30
  let player_damage2 = 0

  let monHP = 300
  let monMaxHP = 300
  let monAtk = 10
  let monEx = 0
  let monCoins = 0
  
  let turn = ''

  let o_atk = 5//基础攻击力
  let w_atk = 0//武器攻击力
  let m_atk = 0//攻击力加成
  let w_m_atk = 0//武器攻击力加成

  let o_spell_power=10
  let w_spell_power=0
  let m_spell_power=0
  let w_m_spell_power=0
  
  let o_speed=90
  let w_speed=0
  let m_speed=0
  let w_m_speed=0

  let o_crit_dmg=50
  let w_crit_dmg=0

  let o_crit_rate=5
  let w_crit_rate=0

  let o_defense=30
  let w_defense=0
  let m_defense=0
  let w_m_defense=0

  //临时数值
  let t_atk = 0
  let t_spell_power = 0
  let t_speed = 0
  let t_crit_rate = 0
  let t_crit_dmg = 0
  let t_defense = 0

  let tips = [
    "普通攻击会回复10点魔力值",
    "法术伤害不会暴击",
    "速度越高越容易闪避攻击",
    "防御力有减伤效果",
    "wohh,manbo~",
    "游戏阶段分前中后期",
    "武器可以更换,但装备只会获得两次",
    "可以在手机上玩,要开全屏和横屏",
    "战胜一场战斗血瓶会恢复1瓶",
    "血瓶在中期是2瓶,后期3瓶",
    "每升1级可以获得一次祝福",
    "每升3级可以获得一次技能",
    "游戏是原生JS制作"
  ]

  /* ... existing code ... */
// ... existing code ...

// 优化后的武器列表处理函数
function createWeaponList(weaponList, container) {
  weaponList.forEach(weapon => {
    const weaponDiv = document.createElement('div');
    weaponDiv.className = 'weapon-item';
    weaponDiv.innerHTML = `
      <img src="${weapon.src}" alt="${weapon.title}">
      <h3>${weapon.title}</h3>
      <p>${weapon.text1}</p>
      <p>${weapon.text2}</p>
      <p>${weapon.text3}</p>
    `;
    container.appendChild(weaponDiv);
  });
}

// 优化后的装备处理函数
function createEquipmentList(equipmentList, container) {
  equipmentList.forEach(equip => {
    const equipDiv = document.createElement('div');
    equipDiv.className = 'equipment-item';
    equipDiv.innerHTML = `
      <img src="${equip.src}" alt="${equip.title}">
      <h3>${equip.title}</h3>
      <p>${equip.text1}</p>
      <p>${equip.text2}</p>
    `;
    container.appendChild(equipDiv);
  });
}

// ... existing code ...

/* ... existing code ... */
  //#endregion
  //#region 数值清单
    //#region 武器列表
  const weapon_a_list1 = [
    {id:0,src:"./img/a2.png",title:"黑剑",text1:"武器攻击力:42",text2:"暴击率+6%",text3:"近战伤害提升10%",apply(){w_atk=42;w_crit_rate=6;w_m_jingzhan=10}},
    {id:1,src:"./img/a3.png",title:"祭礼剑",text1:"武器攻击力:52",text2:"速度+10",text3:"速度+10",apply(){w_atk=52;w_speed=20}},
    {id:2,src:"./img/a4.png",title:"灰河渡手",text1:"武器攻击力:42",text2:"暴击率+5%",text3:"水元素伤害提升10%",apply(){w_atk=42;w_crit_rate=5;w_m_water=10}},
    {id:3,src:"./img/a5.png",title:"笼钓瓶一心",text1:"武器攻击力:42",text2:"攻击力+10%",text3:"火元素伤害提升10%",apply(){w_atk=42;w_m_atk=10;w_m_fire=10}},
    {id:4,src:"./img/a6.png",title:"原木刀",text1:"武器攻击力:44",text2:"速度+10",text3:"风元素伤害提升10%",apply(){w_atk=42;w_speed=10;w_m_wind=10}}
  ]
  const weapon_a_list2 = [
    {id:0,src:"./img/a7.png",title:"裁断",text1:"武器攻击力:123",text2:"暴击率+22%",text3:"近战伤害加成30%",apply(){w_atk=123;w_crit_rate=22;w_m_jingzhan=30}},
    {id:1,src:"./img/a8.png",title:"赤角石溃杵",text1:"武器攻击力:113",text2:"暴击伤害+33%",text3:"火元素伤害提升30%",apply(){w_atk=113;w_crit_dmg=33;w_m_fire=30}},
    {id:2,src:"./img/a9.png",title:"雾切之回光",text1:"武器攻击力:120",text2:"最大生命值永久增加350",text3:"速度+15%",apply(){w_atk=120;maxHP+=350;HP+=350;w_m_speed=15}},
    {id:3,src:"./img/a10.png",title:"松籁",text1:"武器攻击力:135",text2:"攻击力+25%",text3:"风元素伤害提升30%",apply(){w_atk=135;w_m_atk=25;w_m_wind=30}},
    {id:4,src:"./img/a11.png",title:"静水流涌",text1:"武器攻击力:110",text2:"暴击率+22%",text3:"水元素伤害提升30%",apply(){w_atk=110;w_crit_rate=22;w_m_water=30}}
  ]
  const weapon_b_list1 = [
    {id:0,src:'./img/b2.png',title:"烈阳之嗣",text1:"武器攻击力:44",text2:"暴击率+4%",text3:"火元素伤害提升10%",apply(){w_atk=44;w_crit_rate=4;w_m_fire=10}},
    {id:1,src:"./img/b3.png",title:"竭泽",text1:"武器攻击力:42",text2:"速度+10",text3:"水元素伤害提升10%",apply(){w_atk=44;w_speed=10;w_m_water=10}},
    {id:2,src:"./img/b4.png",title:"觅食者",text1:"武器攻击力:42",text2:"暴击+8%",text3:"远程伤害提升10%",apply(){w_atk=42;w_crit_rate=8;w_m_yuancheng=10}},
    {id:3,src:"./img/b5.png",title:"幽夜华尔兹",text1:"武器攻击力:52",text2:"速度+10",text3:"速度+10",apply(){w_atk=52;w_speed=20}},
    {id:4,src:"./img/b6.png",title:"苍翠绿弓",text1:"武器攻击力:42",text2:"攻击力+15%",text3:"风元素伤害提升10%",apply(){w_atk=42;w_m_atk=15;w_m_wind=10}},
  ]
  const weapon_b_list2 = [
    {id:0,src:'./img/b7.png',title:"阿莫斯",text1:"武器攻击力:132",text2:"暴击率+25%",text3:"远程伤害提升30%",apply(){w_atk=132;w_crit_rate=25;w_m_yuancheng=30}},
    {id:2,src:"./img/b8.png",title:"大魔术",text1:"武器攻击力:132",text2:"暴击伤害+35%",text3:"火元素伤害提升30%",apply(){w_atk=132;w_crit_dmg=35;w_m_fire=30}},
    {id:1,src:"./img/b9.png",title:"若水",text1:"武器攻击力:120",text2:"速度+10%",text3:"水元素伤害提升30%",apply(){w_atk=120;w_speed=10;w_m_water=30}},
    {id:3,src:"./img/b10.png",title:"猎人之径",text1:"武器攻击力:120",text2:"攻击力+25%",text3:"风元素伤害提升30%",apply(){w_atk=120;w_m_atk=25;w_m_wind=30}},
    {id:4,src:"./img/b11.png",title:"白雨心弦",text1:"武器攻击力:120",text2:"最大生命值永久增加300",text3:"速度+12%",apply(){w_atk=120;maxHP+=300;HP+=300;w_m_speed=12}},
  ]
  const weapon_c_list1 = [
    {id:0,src:'./img/2.png',title:"嘟可故事集",text1:"武器法术强度:41",text2:"法术强度+12%",text3:"火元素伤害提升15%",apply(){w_spell_power=41;w_m_spell_power=12;w_m_fire=15}},
    {id:2,src:"./img/3.png",title:"暗巷酒与诗",text1:"武器法术强度:44",text2:"速度+10",text3:"水元素伤害提升15%",apply(){w_spell_power=44;w_speed=10;w_m_water=15}},
    {id:1,src:"./img/4.png",title:"匣里日月",text1:"武器法术强度:42",text2:"法术强度+12%",text3:"法术伤害提升12%",apply(){w_spell_power=42;w_m_spell_power=12;w_m_fashu=12}},
    {id:3,src:"./img/5.png",title:"流浪乐章",text1:"武器法术强度:42",text2:"法力值永久增加25",text3:"风元素伤害提升10%",apply(){w_spell_power=42;maxMP+=25;MP+=25;w_m_wind=10}},
    {id:4,src:"./img/6.png",title:"黑岩绯玉",text1:"武器法术强度:52",text2:"法力值永久增加30",text3:"速度+10",apply(){w_spell_power=52;maxMP+=30;MP+=30;w_speed=10}},
  ]
  const weapon_c_list2 = [
    {id:0,src:'./img/7.png',title:"鹤鸣余音",text1:"武器法术强度:145",text2:"法术强度+28%",text3:"风元素伤害提升40%",apply(){w_spell_power=145;w_m_spell_power=28;w_m_wind=40}},
    {id:2,src:"./img/8.png",title:"金流监督",text1:"武器法术强度:133",text2:"速度+10%",text3:"水元素伤害提升40%",apply(){w_spell_power=133;w_m_speed=10;w_m_water=40}},
    {id:3,src:"./img/9.png",title:"不灭月华",text1:"武器法术强度:122",text2:"法力值永久增加60",text3:"火元素伤害提升40%",apply(){w_spell_power=122;maxMP+=60;MP+=60;w_m_fire=40;}},
    {id:1,src:"./img/10.png",title:"尘世之锁",text1:"武器法术强度:122",text2:"法术强度+24%",text3:"法术伤害提升35%",apply(){w_spell_power=122;w_m_spell_power=24;w_m_fashu=35}},
    {id:4,src:"./img/11.png",title:"千夜浮梦",text1:"武器法术强度:155",text2:"法力值永久增加60",text3:"速度+12%",apply(){w_spell_power=155;maxMP+=60;w_m_speed=12}},
  ]
  //#endregion
    //#region 装备列表
    const equi_list1 = [
      {id:0,src:"./img/q1.png",title:"羽衣",text1:"最大生命值+300",text2:"暴击率+8%",apply(){maxHP+=300;HP+=300;o_crit_rate+=8}},
      {id:1,src:"./img/q3.png",title:"缚束",text1:"最大生命值+200",text2:"水元素伤害加成20%",apply(){maxHP+=200;HP+=200;m_water+=20;}},
      {id:2,src:"./img/q5.png",title:"挎包",text1:"最大生命值+150",text2:"速度+15%",apply(){maxHP+=150;HP+=150;m_speed+=15}},
      {id:3,src:"./img/q7.png",title:"瓷甲",text1:"最大生命值+200",text2:"风元素伤害加成20%",apply(){maxHP+=200;HP+=200;m_wind+=20}},
      {id:4,src:"./img/q9.png",title:"铅衣",text1:"最大生命值+200",text2:"近战伤害加成20%",apply(){maxHP+=200;HP+=200;m_jingzhan+=20}},
      {id:5,src:"./img/q11.png",title:"长袍",text1:"最大生命值+200",text2:"火元素伤害加成20%",apply(){maxHP+=200;HP+=200;m_fire+=20}},
      {id:6,src:"./img/q13.png",title:"礼服",text1:"最大生命值+200",text2:"法术伤害加成15%",apply(){maxHP+=200;HP+=200;m_fashu+=15}},
      {id:7,src:"./img/q15.png",title:"银影装甲",text1:"最大生命值+200",text2:"远程伤害加成20%",apply(){maxHP+=200;HP+=200;m_yuancheng+=20}},
    ]
    const equi_list2 = [
      {id:0,src:"./img/q2.png",title:"丝屡",text1:"最大生命值+200",text2:"暴击伤害+16%",apply(){maxHP+=200;HP+=200;o_crit_dmg+=16}},
      {id:1,src:"./img/q4.png",title:"锁桎",text1:"最大法力值+100",text2:"水元素伤害加成20%",apply(){maxMP+=100;MP+=100;m_water+=20}},
      {id:2,src:"./img/q6.png",title:"板鞋",text1:"攻击力加成20%",text2:"速度+15%",apply(){m_atk+=20;m_speed+=15}},
      {id:3,src:"./img/q8.png",title:"腿甲",text1:"最大法力值+100",text2:"风元素伤害加成20%",apply(){maxMP+=100;MP+=100;m_wind+=20}},
      {id:4,src:"./img/q10.png",title:"桩锚",text1:"攻击力加成20%",text2:"近战伤害加成20%",apply(){m_atk+=20;m_jingzhan+=20}},
      {id:5,src:"./img/q12.png",title:"礼鞋",text1:"最大法力值+100",text2:"火元素伤害加成20%",apply(){maxMP+=100;MP+=100;m_fire+=20}},
      {id:6,src:"./img/q14.png",title:"革履",text1:"最大法力值+100",text2:"法术伤害加成15%",apply(){maxMP+=100;MP+=100;m_fashu+=15}},
      {id:7,src:"./img/q16.png",title:"护胫",text1:"攻击力加成20%",text2:"远程伤害加成20%",apply(){m_atk+=20;m_yuancheng+=20}},
    ]
    //#endregion
    //#region 祝福列表
    const attribute_list = [
      {id:0,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+5',apply(){o_atk+=5}},
      {id:1,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+10',apply(){o_atk+=10}},
      {id:2,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+15',apply(){o_atk+=15}},
      {id:3,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+20',apply(){o_atk+=20}},
      {id:4,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+25',apply(){o_atk+=25}},
      {id:5,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+30',apply(){o_atk+=30}},
      {id:6,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+7',apply(){o_atk+=7}},
      {id:7,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+14',apply(){o_atk+=14}},
      {id:8,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+3',apply(){o_atk+=3}},
      {id:9,src:"./img/基础攻击.png",title:"攻击力",text:'基础攻击力+6',apply(){o_atk+=6}},
  
      {id:10,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+5%',apply(){m_atk+=5}},
      {id:11,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+10%',apply(){m_atk+=10}},
      {id:12,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+15%',apply(){m_atk+=15}},
      {id:13,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+20%',apply(){m_atk+=20}},
      {id:14,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+3%',apply(){m_atk+=3}},
      {id:15,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+6%',apply(){m_atk+=6}},
      {id:16,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+9%',apply(){m_atk+=9}},
      {id:17,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+12%',apply(){m_atk+=12}},
      {id:18,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+16%',apply(){m_atk+=16}},
      {id:19,src:"./img/攻击力加成.png",title:"攻击力",text:'攻击力加成+8%',apply(){m_atk+=8}},
  
      {id:20,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+5',apply(){o_spell_power+=5}},
      {id:21,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+10',apply(){o_spell_power+=10}},
      {id:22,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+15',apply(){o_spell_power+=15}},
      {id:23,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+20',apply(){o_spell_power+=20}},
      {id:24,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+25',apply(){o_spell_power+=25}},
      {id:25,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+30',apply(){o_spell_power+=30}},
      {id:26,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+7',apply(){o_spell_power+=7}},
      {id:27,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+14',apply(){o_spell_power+=14}},
      {id:28,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+3',apply(){o_spell_power+=3}},
      {id:29,src:"./img/法术强度.png",title:"法术强度",text:'基础法术强度+6',apply(){o_spell_power+=6}},
  
      {id:30,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+5%',apply(){m_spell_power+=5}},
      {id:31,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+10%',apply(){m_spell_power+=10}},
      {id:32,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+15%',apply(){m_spell_power+=15}},
      {id:33,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+20%',apply(){m_spell_power+=20}},
      {id:34,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+3%',apply(){m_spell_power+=3}},
      {id:35,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+6%',apply(){m_spell_power+=6}},
      {id:36,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+9%',apply(){m_spell_power+=9}},
      {id:37,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+12%',apply(){m_spell_power+=12}},
      {id:38,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+16%',apply(){m_spell_power+=16}},
      {id:39,src:"./img/法强加成.png",title:"法术强度",text:'法强加成+8%',apply(){m_spell_power+=8}},
  
      {id:40,src:"./img/速度.png",title:"速度",text:'基础速度+1',apply(){o_speed+=1}},
      {id:41,src:"./img/速度.png",title:"速度",text:'基础速度+2',apply(){o_speed+=2}},
      {id:42,src:"./img/速度.png",title:"速度",text:'基础速度+3',apply(){o_speed+=3}},
      {id:43,src:"./img/速度.png",title:"速度",text:'基础速度+4',apply(){o_speed+=4}},
      {id:44,src:"./img/速度.png",title:"速度",text:'基础速度+5',apply(){o_speed+=5}},
      {id:45,src:"./img/速度.png",title:"速度",text:'基础速度+6',apply(){o_speed+=6}},
      {id:46,src:"./img/速度.png",title:"速度",text:'基础速度+7',apply(){o_speed+=7}},
      {id:47,src:"./img/速度.png",title:"速度",text:'基础速度+8',apply(){o_speed+=8}},
      {id:48,src:"./img/速度.png",title:"速度",text:'基础速度+9',apply(){o_speed+=9}},
      {id:49,src:"./img/速度.png",title:"速度",text:'基础速度+10',apply(){o_speed+=10}},
  
      
  
      {id:70,src:"./img/防御力.png",title:"防御力",text:'基础防御力+5',apply(){o_defense+=5}},
      {id:71,src:"./img/防御力.png",title:"防御力",text:'基础防御力+10',apply(){o_defense+=10}},
      {id:72,src:"./img/防御力.png",title:"防御力",text:'基础防御力+15',apply(){o_defense+=15}},
      {id:73,src:"./img/防御力.png",title:"防御力",text:'基础防御力+20',apply(){o_defense+=20}},
      {id:74,src:"./img/防御力.png",title:"防御力",text:'基础防御力+25',apply(){o_defense+=25}},
      {id:75,src:"./img/防御力.png",title:"防御力",text:'基础防御力+30',apply(){o_defense+=30}},
      {id:76,src:"./img/防御力.png",title:"防御力",text:'基础防御力+12',apply(){o_defense+=12}},
      {id:77,src:"./img/防御力.png",title:"防御力",text:'基础防御力+16',apply(){o_defense+=16}},
      {id:78,src:"./img/防御力.png",title:"防御力",text:'基础防御力+8',apply(){o_defense+=8}},
      {id:79,src:"./img/防御力.png",title:"防御力",text:'基础防御力+6',apply(){o_defense+=6}},
  
      {id:80,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+3%',apply(){m_defense+=3}},
      {id:81,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+5%',apply(){m_defense+=5}},
      {id:82,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+6%',apply(){m_defense+=6}},
      {id:83,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+7%',apply(){m_defense+=7}},
      {id:84,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+10%',apply(){m_defense+=10}},
      {id:85,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+12%',apply(){m_defense+=12}},
      {id:86,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+15%',apply(){m_defense+=15}},
      {id:87,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+16%',apply(){m_defense+=16}},
      {id:88,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+8%',apply(){m_defense+=8}},
      {id:89,src:"./img/防御力加成.png",title:"防御力",text:'防御力加成+20%',apply(){m_defense+=20}},
    ]
    //#endregion
    //#region 技能列表
    //战士
    const a_skill_list1 = [
      {id:0,skill_title:"轻击",skill_consume:"25",skill_text:"对敌人造成130%近战伤害,协同暴击率10%"},
      {id:1,skill_title:"火刃",skill_consume:"25",skill_text:"对敌人造成120%火属性物理伤害"},
      {id:2,skill_title:"水刃",skill_consume:"25",skill_text:"对敌人造成120%水属性物理伤害"},
      {id:3,skill_title:"风刃",skill_consume:"25",skill_text:"对敌人造成120%风属性物理伤害"},
      {id:4,skill_title:"手术刀",skill_consume:"20",skill_text:"对敌人造成100%物理伤害,并回复20HP"},
      {id:5,skill_title:"举盾",skill_consume:"10",skill_text:"增加30点防御力,持续一回合,造成150%防御力伤害"},
    ]
    const a_skill_list2 = [
      {id:6,skill_title:"重刃",skill_consume:"30",skill_text:"对敌人造成150%近战伤害,协同暴击率25%"},
      {id:7,skill_title:"烈阳刃",skill_consume:"30",skill_text:"对敌人造成140%火属性物理伤害"},
      {id:8,skill_title:"涟漪刃",skill_consume:"30",skill_text:"对敌人造成140%水属性物理伤害"},
      {id:9,skill_title:"摇曳刃",skill_consume:"30",skill_text:"对敌人造成140%风属性物理伤害"},
      {id:10,skill_title:"魔术飞刀",skill_consume:"25",skill_text:"对敌人造成120%物理伤害,并回复30HP"},
      {id:11,skill_title:"盾击",skill_consume:"15",skill_text:"增加50点防御力,持续一回合,造成200%防御力伤害"},
    ]
    const a_skill_list3 = [
      {id:12,skill_title:"蓄力猛击",skill_consume:"35",skill_text:"对敌人造成200%物理伤害,协同暴击率40%"},
      {id:13,skill_title:"残阳刃",skill_consume:"35",skill_text:"对敌人造成180%火属性物理伤害"},
      {id:14,skill_title:"水帘刃",skill_consume:"35",skill_text:"对敌人造成180%水属性物理伤害"},
      {id:15,skill_title:"扶摇刃",skill_consume:"35",skill_text:"对敌人造成180%风属性物理伤害"},
      {id:16,skill_title:"吸血鬼飞刀",skill_consume:"30",skill_text:"对敌人造成140%物理伤害,并回复50HP"},
      {id:17,skill_title:"盾冲",skill_consume:"20",skill_text:"增加100点防御力,持续一回合,造成250%防御力伤害"},
    ]
    //射手
    const b_skill_list1 = [
      {id:18,skill_title:"蓄力一击",skill_consume:"25",skill_text:"对敌人造成130%远程伤害,协同暴击伤害20%"},
      {id:19,skill_title:"火弩",skill_consume:"25",skill_text:"对敌人造成120%火属性物理伤害"},
      {id:20,skill_title:"水矢",skill_consume:"25",skill_text:"对敌人造成120%水属性物理伤害"},
      {id:21,skill_title:"风箭",skill_consume:"25",skill_text:"对敌人造成120%风属性物理伤害"},
      {id:22,skill_title:"干净小手",skill_consume:"20",skill_text:"增加25点速度,持续一回合,造成100%远程伤害"},
    ]
    const b_skill_list2 = [
      {id:23,skill_title:"箭雨",skill_consume:"30",skill_text:"对敌人造成150%远程伤害,协同暴击伤害50%"},
      {id:24,skill_title:"残阳连弩",skill_consume:"30",skill_text:"对敌人造成140%火属性物理伤害"},
      {id:25,skill_title:"水箭复合弓",skill_consume:"30",skill_text:"对敌人造成140%水属性物理伤害"},
      {id:26,skill_title:"风镖发射器",skill_consume:"30",skill_text:"对敌人造成140%风属性物理伤害"},
      {id:27,skill_title:"不干净小手",skill_consume:"25",skill_text:"增加35点速度,持续一回合,造成120%远程伤害"},
    ]
    const b_skill_list3 = [
      {id:28,skill_title:"死神之眼",skill_consume:"35",skill_text:"对敌人造成200%远程伤害,协同暴击伤害80%"},
      {id:29,skill_title:"日曜喷发器",skill_consume:"35",skill_text:"对敌人造成180%火属性物理伤害"},
      {id:30,skill_title:"利维坦之牙",skill_consume:"35",skill_text:"对敌人造成180%水属性物理伤害"},
      {id:31,skill_title:"音速风刺",skill_consume:"35",skill_text:"对敌人造成180%风属性物理伤害"},
      {id:32,skill_title:"小手不是很干净",skill_consume:"30",skill_text:"增加45点速度,持续一回合,造成140%远程伤害"},
    ]
    //法师
    const c_skill_list1 = [
      {id:33,skill_title:"屏息",skill_consume:"10",skill_text:"增加50点防御力,持续一回合,并回复30法力值"},
      {id:34,skill_title:"挥杖",skill_consume:"30",skill_text:"对敌人造成130%法术伤害"},
      {id:35,skill_title:"火苗",skill_consume:"30",skill_text:"对敌人造成120%火属性法术伤害"},
      {id:36,skill_title:"水箭",skill_consume:"30",skill_text:"对敌人造成120%水属性法术伤害"},
      {id:37,skill_title:"风弹",skill_consume:"30",skill_text:"对敌人造成120%风属性法术伤害"},
    ]
    const c_skill_list2 = [
      {id:38,skill_title:"凝神",skill_consume:"10",skill_text:"增加80点防御力,持续一回合,并回复40法力值"},
      {id:39,skill_title:"摆阵",skill_consume:"35",skill_text:"对敌人造成160%法术伤害"},
      {id:40,skill_title:"爆炸法术",skill_consume:"35",skill_text:"对敌人造成150%火属性法术伤害"},
      {id:41,skill_title:"水箭雨",skill_consume:"35",skill_text:"对敌人造成150%水属性法术伤害"},
      {id:42,skill_title:"龙卷风",skill_consume:"35",skill_text:"对敌人造成150%风属性法术伤害"},
    ]
    const c_skill_list3 = [
      {id:43,skill_title:"禅定",skill_consume:"10",skill_text:"增加120点防御力,持续一回合,并回复50法力值"},
      {id:44,skill_title:"杀人魔法",skill_consume:"40",skill_text:"对敌人造成200%法术伤害"},
      {id:45,skill_title:"火焰艺术",skill_consume:"40",skill_text:"对敌人造成200%火属性法术伤害"},
      {id:46,skill_title:"水域囚牢",skill_consume:"40",skill_text:"对敌人造成200%水属性法术伤害"},
      {id:47,skill_title:"噬空风兽",skill_consume:"40",skill_text:"对敌人造成200%风属性法术伤害"},
    ]
    //#endregion
    //#region 道具列表
    const prop_list = [
      {id:0,src:"./img/生命1.png",title:"丰饶之种",text:"生命值+30",apply(){maxHP+=30;HP+=30}},
      {id:1,src:"./img/生命2.png",title:"生命之芽",text:"生命值+40",apply(){maxHP+=40;HP+=40}},
      {id:2,src:"./img/生命3.png",title:"永恒之花",text:"生命值+50",apply(){maxHP+=50;HP+=50}},
      {id:3,src:"./img/防御1.png",title:"散逸星砂",text:"防御力+10%",apply(){m_defense+=10}},
      {id:4,src:"./img/防御2.png",title:"流星棱晶",text:"防御力+20%",apply(){m_defense+=20}},
      {id:5,src:"./img/防御3.png",title:"神体琥珀",text:"防御力+30%",apply(){m_defense+=30}},
      {id:6,src:"./img/速度1.png",title:"古代零件",text:"速度+5%",apply(){m_speed+=5}},
      {id:7,src:"./img/速度2.png",title:"古代转轴",text:"速度+7%",apply(){m_speed+=7}},
      {id:8,src:"./img/速度3.png",title:"古代引擎",text:"速度+9%",apply(){m_speed+=9}},
      {id:9,src:"./img/爆伤1.png",title:"步离犬牙",text:"暴击伤害+10%",apply(){o_crit_dmg+=10}},
      {id:10,src:"./img/爆伤2.png",title:"狼毒锯牙",text:"暴击伤害+13%",apply(){o_crit_dmg+=13}},
      {id:11,src:"./img/爆伤3.png",title:"月狂獠牙",text:"暴击伤害+16%",apply(){o_crit_dmg+=16}},
      {id:12,src:"./img/暴击1.png",title:"陨铁弹丸",text:"暴击率+5%",apply(){o_crit_rate+=5}},
      {id:13,src:"./img/暴击2.png",title:"命定死因",text:"暴击率+6%",apply(){o_crit_rate+=6}},
      {id:14,src:"./img/暴击3.png",title:"逆时一击",text:"暴击率+8%",apply(){o_crit_rate+=8}},
      {id:15,src:"./img/法术1.png",title:"黯淡黑曜",text:"法术伤害加成8%",apply(){m_fashu+=8}},
      {id:16,src:"./img/法术2.png",title:"虚空黑曜",text:"法术伤害加成10%",apply(){m_fashu+=10}},
      {id:17,src:"./img/法术3.png",title:"沉沦黑曜",text:"法术伤害加成12%",apply(){m_fashu+=12}},
      {id:18,src:"./img/近战1.png",title:"破碎残刃",text:"近战伤害加成8%",apply(){m_jingzhan+=8}},
      {id:19,src:"./img/近战2.png",title:"无生残刃",text:"近战伤害加成10%",apply(){m_jingzhan+=10}},
      {id:20,src:"./img/近战3.png",title:"净世残刃",text:"近战伤害加成12%",apply(){m_jingzhan+=12}},
      {id:21,src:"./img/远程1.png",title:"猎兽之矢",text:"远程伤害加成8%",apply(){m_yuancheng+=8}},
      {id:22,src:"./img/远程2.png",title:"屠魔之矢",text:"远程伤害加成10%",apply(){m_yuancheng+=10}},
      {id:23,src:"./img/远程3.png",title:"逐星之矢",text:"远程伤害加成12%",apply(){m_yuancheng+=12}},
      {id:24,src:"./img/风1.png",title:"气态流体",text:"风元素伤害加成12%",apply(){m_wind+=12}},
      {id:25,src:"./img/风2.png",title:"风之旋",text:"风元素伤害加成14%",apply(){m_wind+=14}},
      {id:26,src:"./img/风3.png",title:"丰饶香涎",text:"风元素伤害加成16%",apply(){m_wind+=16}},
      {id:27,src:"./img/风4.png",title:"换境树叶",text:"风元素伤害加成18%",apply(){m_wind+=18}},
      {id:28,src:"./img/水1.png",title:"固态净水",text:"水元素伤害加成12%",apply(){m_water+=12}},
      {id:29,src:"./img/水2.png",title:"冰之芯",text:"水元素伤害加成14%",apply(){m_water+=14}},
      {id:30,src:"./img/水3.png",title:"龙鳞珊瑚",text:"水元素伤害加成16%",apply(){m_water+=16}},
      {id:31,src:"./img/水4.png",title:"迷思绳结",text:"水元素伤害加成18%",apply(){m_water+=18}},
      {id:32,src:"./img/火1.png",title:"燃素",text:"火元素伤害加成12%",apply(){m_fire+=12}},
      {id:33,src:"./img/火2.png",title:"火之翎",text:"火元素伤害加成14%",apply(){m_fire+=14}},
      {id:34,src:"./img/火3.png",title:"毁灭异质",text:"火元素伤害加成16%",apply(){m_fire+=16}},
      {id:35,src:"./img/火4.png",title:"相位灵火",text:"火元素伤害加成18%",apply(){m_fire+=18}},
    ]
    //#endregion
    //#region 怪物列表
    const mon_list1 = [
      {src:"./img/creature.gif",monHP:203,monAtk:25,monEx:120,monCoins:10},
      {src:"./img/creature (1).gif",monHP:220,monAtk:25,monEx:130,monCoins:11},
      {src:"./img/creature (2).gif",monHP:215,monAtk:23,monEx:126,monCoins:12},
      {src:"./img/creature (3).gif",monHP:223,monAtk:29,monEx:112,monCoins:13},
      {src:"./img/creature (4).gif",monHP:214,monAtk:28,monEx:123,monCoins:14},
    ]
    const mon_list2 = [
      {src:"./img/creature (5).gif",monHP:640,monAtk:50,monEx:206,monCoins:30},
      {src:"./img/creature (6).gif",monHP:636,monAtk:67,monEx:198,monCoins:32},
      {src:"./img/creature (7).gif",monHP:614,monAtk:66,monEx:199,monCoins:41},
      {src:"./img/creature (8).gif",monHP:625,monAtk:65,monEx:214,monCoins:33},
      {src:"./img/creature (9).gif",monHP:629,monAtk:68,monEx:203,monCoins:44},
    ]
    const mon_list3 =[
      {src:"./img/creature (10).gif",monHP:1740,monAtk:50,monEx:270,monCoins:60},
      {src:"./img/creature (11).gif",monHP:1690,monAtk:53,monEx:280,monCoins:50},
      {src:"./img/creature (12).gif",monHP:1710,monAtk:54,monEx:296,monCoins:57},
      {src:"./img/creature (13).gif",monHP:1650,monAtk:52,monEx:278,monCoins:63},
      {src:"./img/creature (14).gif",monHP:1688,monAtk:58,monEx:293,monCoins:62},
    ]
    const boss_list =[
      {src:"./img/boss1.gif",monHP:300,monAtk:30,monEx:270,monCoins:60},
      {src:"./img/boss2.gif",monHP:800,monAtk:60,monEx:280,monCoins:70},
      {src:"./img/boss3.gif",monHP:2200,monAtk:90,monEx:0,monCoins:999},
    ]
    //#endregion
    //#endregion
  //武器数值清零
    function w_reset(){
    w_m_jingzhan=0
    w_m_yuancheng=0
    w_m_fashu=0
    w_m_fire=0
    w_m_water=0
    w_m_wind=0
    w_atk = 0
    w_m_atk = 0
    w_spell_power=0
    w_m_spell_power=0
    w_speed=0
    w_m_speed=0
    w_crit_dmg=0
    w_crit_rate=0
    w_defense=0
    w_m_defense=0
  }
  //文字浮现函数
  function word1(text){
    let index = 0; // 当前字符的索引
    let word = ''
    let typingInterval = setInterval(function() {
    if (index < text.length) {
      word += text.charAt(index)
      document.querySelector('.typing-text').innerText = word
      index++;
    } else {
      clearInterval(typingInterval); // 停止定时器
    }
  }, 80); // 每个字符之间的时间间隔，单位为毫秒
  setTimeout(function(){
    document.querySelector('.typing-text').innerText = ''
  },1500)
  }
  //文字跳动函数
  function word2(text,size,color,time){
    const jt = document.querySelector('.jumping-text')
    jt.innerText = text
    jt.style.color = color
    jt.style.opacity = 1
    jt.style.fontSize = size + 'px'
    jt.style.animationPlayState = "running"
    setTimeout(function(){
      jt.style.opacity = 0
      setTimeout(function(){
        jt.style.animationPlayState = "paused"
      },time-1100)
    },1100)
  }
  //#region blessings二层数据
  document.querySelector('.attribute2').addEventListener('mouseenter',function(){
    document.querySelector('.attribute2').style.opacity = 1
  })
  document.querySelector('.attribute2').addEventListener('mouseleave',function(){
    document.querySelector('.attribute2').style.opacity = 0
  })
  //#endregion

  //#region 背包二层
  document.querySelector('.left-mid .wea_img').addEventListener('mouseenter',function(){
    document.querySelector('.left-top2').style.opacity = 1
  })
  document.querySelector('.left-mid .wea_img').addEventListener('mouseleave',function(){
    document.querySelector('.left-top2').style.opacity = 0
  })
  document.querySelector('.left-mid .equ_img1').addEventListener('mouseenter',function(){
    document.querySelector('.left-top3').style.opacity = 1
  })
  document.querySelector('.left-mid .equ_img1').addEventListener('mouseleave',function(){
    document.querySelector('.left-top3').style.opacity = 0
  })
  document.querySelector('.left-mid .equ_img2').addEventListener('mouseenter',function(){
    document.querySelector('.left-top4').style.opacity = 1
  })
  document.querySelector('.left-mid .equ_img2').addEventListener('mouseleave',function(){
    document.querySelector('.left-top4').style.opacity = 0
  })
  //#endregion

  //渲染背包函数
  function packbag_refresh(){
    document.querySelector('.wea_img').src = wea_src
    document.querySelector('.equ_img1').src = equ_src1
    document.querySelector('.equ_img2').src = equ_src2
    

    document.querySelector('.wea_title').innerText = wea_title
    document.querySelector('.wea_text1').innerText = `●${wea_text1}`
    document.querySelector('.wea_text2').innerText = `●${wea_text2}`
    document.querySelector('.wea_text3').innerText = `●${wea_text3}`

    document.querySelector('.equ_title1').innerText = equ_title1
    document.querySelector('.equ_title2').innerText = equ_title2
    document.querySelector('.equ_text1_1').innerText = `●${equ_text1_1}`
    document.querySelector('.equ_text2_1').innerText = `●${equ_text2_1}`
    document.querySelector('.equ_text1_2').innerText = `●${equ_text1_2}`
    document.querySelector('.equ_text2_2').innerText = `●${equ_text2_2}`

    document.querySelector('.left-bottom').innerHTML = pro_list

    if(flag === 0){document.querySelector('.flag').innerText = '前 期'}
    else if(flag === 1){document.querySelector('.flag').innerText = '中 期'}
    else if(flag === 2){document.querySelector('.flag').innerText = '后 期'}
  }
  packbag_refresh()
  //渲染能力函数
  function ability_refresh(){
  // 数值计算公式
  // 攻击力=（基础攻击力+武器攻击力）* （1+攻击力加成%+武器攻击加成%）
    atk = Math.floor((o_atk+w_atk+t_atk)*(1+m_atk*0.01+w_m_atk*0.01))
  // 法术强度=（基础法强+武器法强）* （1+法强加成%+武器法强加成%）
    spell_power = Math.floor((o_spell_power+w_spell_power+t_spell_power)*(1+m_spell_power*0.01+w_m_spell_power*0.01))
  // 速度= （基础速度+武器速度）*（1+速度加成）
    speed = Math.floor((o_speed+w_speed+t_speed)*(1+m_speed*0.01+w_m_speed*0.01))
  // 暴击率= 基础暴击+武器暴击
    crit_rate = Math.floor(o_crit_rate+w_crit_rate+t_crit_rate)
  // 暴击伤害=基础爆伤+武器爆伤
    crit_dmg = Math.floor(o_crit_dmg+w_crit_dmg+t_crit_dmg)
  // 防御力=（基础防御+武器防御）*（1+防御力加成+武器防御力加成%）
    defense = Math.floor((o_defense+w_defense+t_defense)*(1+m_defense*0.01+w_defense*0.01))

    jingzhan = Math.floor(m_jingzhan+w_m_jingzhan)
    yuancheng = Math.floor(m_yuancheng+w_m_yuancheng)
    fashu = Math.floor(m_fashu+w_m_fashu)
    fire = Math.floor(m_fire+w_m_fire)
    water = Math.floor(m_water+w_m_water)
    wind = Math.floor(m_wind+w_m_wind)

    document.querySelector('.ATK').innerText = atk
    document.querySelector('.SPELL-POWER').innerText = spell_power
    document.querySelector('.SPEED').innerText = speed
    document.querySelector('.CRIT-RATE').innerText = crit_rate
    document.querySelector('.CRIT-DMG').innerText = crit_dmg
    document.querySelector('.DEFENSE').innerText = defense
    document.querySelector('.jingzhan').innerText = jingzhan
    document.querySelector('.yuancheng').innerText = yuancheng
    document.querySelector('.fashu').innerText = fashu
    document.querySelector('.fire').innerText = fire
    document.querySelector('.water').innerText = water
    document.querySelector('.wind').innerText = wind

    document.querySelector('.o_atk').innerText = o_atk
    document.querySelector('.w_atk').innerText = w_atk
    document.querySelector('.m_atk').innerText = m_atk
    document.querySelector('.w_m_atk').innerText = w_m_atk

    document.querySelector('.o_spell_power').innerText = o_spell_power
    document.querySelector('.w_spell_power').innerText = w_spell_power
    document.querySelector('.m_spell_power').innerText = m_spell_power
    document.querySelector('.w_m_spell_power').innerText = w_m_spell_power

    document.querySelector('.o_speed').innerText = o_speed
    document.querySelector('.w_speed').innerText = w_speed
    document.querySelector('.m_speed').innerText = m_speed
    document.querySelector('.w_m_speed').innerText = w_m_speed

    document.querySelector('.o_crit_rate').innerText = o_crit_rate
    document.querySelector('.w_crit_rate').innerText = w_crit_rate
    document.querySelector('.o_crit_dmg').innerText = o_crit_dmg
    document.querySelector('.w_crit_dmg').innerText = w_crit_dmg

    document.querySelector('.o_defense').innerText = o_defense
    document.querySelector('.w_defense').innerText = w_defense
    document.querySelector('.m_defense').innerText = m_defense
    document.querySelector('.w_m_defense').innerText = w_m_defense

    document.querySelector('.m_jingzhan').innerText = m_jingzhan
    document.querySelector('.m_yuancheng').innerText = m_yuancheng
    document.querySelector('.m_fashu').innerText = m_fashu
    document.querySelector('.m_fire').innerText = m_fire
    document.querySelector('.m_water').innerText = m_water
    document.querySelector('.m_wind').innerText = m_wind

    document.querySelector('.w_m_jingzhan').innerText = w_m_jingzhan
    document.querySelector('.w_m_yuancheng').innerText = w_m_yuancheng
    document.querySelector('.w_m_fashu').innerText = w_m_fashu
    document.querySelector('.w_m_fire').innerText = w_m_fire
    document.querySelector('.w_m_water').innerText = w_m_water
    document.querySelector('.w_m_wind').innerText = w_m_wind
  }
  ability_refresh()
  //渲染生命值、魔力值函数
  function HPMP_refresh(){
    let health_bar = document.querySelector('.health-bar')
    health_bar.style.width = HP*100/maxHP + '%'
    health_bar.innerHTML = HP + '/' + maxHP
    if(HP*100/maxHP>30){
      health_bar.style.backgroundColor = '#4CAF50'
    }
    else if(HP*100/maxHP<=30 && HP*100/maxHP>10){
      health_bar.style.backgroundColor = 'goldenrod'
    }
    else if(HP*100/maxHP<=10){
      health_bar.style.backgroundColor = 'red'
  }

    let magic_bar = document.querySelector('.magic-bar')
    magic_bar.style.width = MP*100/maxMP + '%'
    magic_bar.innerHTML = MP + '/' + maxMP
    if( MP*100/maxMP>30){
      magic_bar.style.backgroundColor = 'rgb(30, 157, 220)'
    }
    else if(MP*100/maxMP<=30 && MP*100/maxMP>10){
      magic_bar.style.backgroundColor = 'goldenrod'
    }
    else if(MP*100/maxMP<=10){
      magic_bar.style.backgroundColor = 'red'
  }



  }
  HPMP_refresh()
  //选择职业函数
  function role(){
    document.querySelector('.role .inbox').innerHTML=`
    <div class="inbox1">
       <img src="./img/无标题b.png" alt="">
       <div class="text1">战士</div>
       <div class="text2">输出与生存能力均衡</div>
       <div class="text2">HP+30 ATK+15</div>
     </div>
     <div class="inbox2">
       <img src="./img/无标题a.png" alt="">
       <div class="text1">法师</div>
       <div class="text2">讲究法术搭配</div>
       <div class="text2">MP+50 法强+15</div>
     </div>
     <div class="inbox3">
       <img src="./img/无标题c.png" alt="">
       <div class="text1">射手</div>
       <div class="text2">高暴击高速度</div>
       <div class="text2">暴击+20% 速度+25</div>
     </div>
   `
   document.querySelector('.role').classList.toggle('show')
   document.querySelector('.role .inbox1').addEventListener('click',function(){
     maxHP+=30
     HP+=30
     o_atk+=15
     m_jingzhan+=5
     w_atk=20
     wea_src='./img/a1.png'
     wea_title='无锋剑'
     wea_text1='武器攻击力:20'
     ability_refresh()
     HPMP_refresh()
     packbag_refresh()
     character = '战士'
     word2('已选择战士！',55,"yellow",1500)
     document.querySelector('.role').classList.toggle('show')
     skill()
   })
    document.querySelector('.role .inbox2').addEventListener('click',function(){
    maxMP+=50
    MP+=50
    o_spell_power+=15
    w_m_fashu+=5
    w_spell_power=20
    wea_src='./img/1.png'
    wea_title='学徒笔记'
    wea_text1='武器魔法强度:20'
    ability_refresh()
    HPMP_refresh()
    packbag_refresh()
    character = '法师'
    word2(`已选择法师！`,55,"yellow",1500)
    document.querySelector('.role').classList.toggle('show')
    skill()
   })
    document.querySelector('.role .inbox3').addEventListener('click',function(){
    o_crit_rate+=30
    o_speed+=25
    w_m_yuancheng+=5
    w_atk=20
    wea_src='./img/b1.png'
    wea_title='猎弓'
    wea_text1='武器攻击力:30'
    ability_refresh()
    HPMP_refresh()
    packbag_refresh()
    character = '射手'
    word2(`已选择射手！`,55,"yellow",1500)
    document.querySelector('.role').classList.toggle('show')
    skill()
   })
  }
  //选择武器函数
  function weapon(){
    let list = []
    if(character === '战士'){
      if(flag === 1){list = [...weapon_a_list1]}
      else if(flag === 2){list = [...weapon_a_list2]}
    }
    else if(character === '射手'){
      if(flag === 1){list = [...weapon_b_list1]}
      else if(flag === 2){list = [...weapon_b_list2]}
    }
    else if(character === '法师'){
      if(flag === 1){list = [...weapon_c_list1]}
      else if(flag === 2){list = [...weapon_c_list2]}
    }

    let random = Math.floor(Math.random()*list.length)
    let obj1 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj2 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj3 = list[random]
    list.splice(random,1)
    
    document.querySelector('.weapon .inbox').innerHTML=`
     <div class="inbox1">
        <img src="${obj1.src}" alt="">
        <div class="text1">${obj1.title}</div>
        <div class="text2">${obj1.text1}</div>
        <div class="text3">●${obj1.text2}</div>
        <div class="text3">●${obj1.text3}</div>
      </div>
      <div class="inbox2">
        <img src="${obj2.src}" alt="">
        <div class="text1">${obj2.title}</div>
        <div class="text2">${obj2.text1}</div>
        <div class="text3">●${obj2.text2}</div>
        <div class="text3">●${obj2.text3}</div>
      </div>
      <div class="inbox3">
        <img src="${obj3.src}" alt="">
        <div class="text1">${obj3.title}</div>
        <div class="text2">${obj3.text1}</div>
        <div class="text3">●${obj3.text2}</div>
        <div class="text3">●${obj3.text3}</div>
      </div>
      `
    document.querySelector('.weapon').classList.toggle('show')
    document.querySelector('.weapon .inbox1').addEventListener('click',function(){
      w_reset()
      obj1.apply()
      wea_src= obj1.src
      wea_title = obj1.title
      wea_text1 = obj1.text1
      wea_text2 = obj1.text2
      wea_text3 = obj1.text3
      ability_refresh()
      HPMP_refresh()
      packbag_refresh()
      word2(`更换为 ${obj1.title} !`,50,"red",1500)
      document.querySelector('.weapon').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.weapon .inbox2').addEventListener('click',function(){
      w_reset()
      obj2.apply()
      wea_src= obj2.src
      wea_title = obj2.title
      wea_text1 = obj2.text1
      wea_text2 = obj2.text2
      wea_text3 = obj2.text3
      ability_refresh()
      HPMP_refresh()
      packbag_refresh()
      word2(`更换为 ${obj2.title} !`,50,"red",1500)
      document.querySelector('.weapon').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.weapon .inbox3').addEventListener('click',function(){
      w_reset()
      obj3.apply()
      wea_src= obj3.src
      wea_title = obj3.title
      wea_text1 = obj3.text1
      wea_text2 = obj3.text2
      wea_text3 = obj3.text3
      ability_refresh()
      HPMP_refresh()
      packbag_refresh()
      word2(`更换为 ${obj3.title} !`,50,"red",1500)
      document.querySelector('.weapon').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
  }
  //选择装备函数
  function equipment(){
    let list = []
      if(flag === 1){list = [...equi_list1]}
      else if(flag === 2){list = [...equi_list2]}
    
    let random = Math.floor(Math.random()*list.length)
    let obj1 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj2 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj3 = list[random]
    list.splice(random,1)
    
    document.querySelector('.equipment .inbox').innerHTML=`
     <div class="inbox1">
        <img src="${obj1.src}" alt="">
        <div class="text1">${obj1.title}</div>
        <div class="text2">${obj1.text1}</div>
        <div class="text3">●${obj1.text2}</div>
      </div>
      <div class="inbox2">
        <img src="${obj2.src}" alt="">
        <div class="text1">${obj2.title}</div>
        <div class="text2">${obj2.text1}</div>
        <div class="text3">●${obj2.text2}</div>
      </div>
      <div class="inbox3">
        <img src="${obj3.src}" alt="">
        <div class="text1">${obj3.title}</div>
        <div class="text2">${obj3.text1}</div>
        <div class="text3">●${obj3.text2}</div>
      </div>
      `

    document.querySelector('.equipment').classList.toggle('show')
    if(flag === 1){
        document.querySelector('.equipment .inbox1').addEventListener('click',function(){
          obj1.apply()
          equ_src1= obj1.src
          equ_title1 = obj1.title
          equ_text1_1 = obj1.text1
          equ_text2_1 = obj1.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj1.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
        document.querySelector('.equipment .inbox2').addEventListener('click',function(){
          obj2.apply()
          equ_src1= obj2.src
          equ_title1 = obj2.title
          equ_text1_1 = obj2.text1
          equ_text2_1 = obj2.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj2.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
        document.querySelector('.equipment .inbox3').addEventListener('click',function(){
          obj3.apply()
          equ_src1= obj3.src
          equ_title1 = obj3.title
          equ_text1_1 = obj3.text1
          equ_text2_1 = obj3.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj3.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
      }
      else if(flag === 2){
        document.querySelector('.equipment .inbox1').addEventListener('click',function(){
          obj1.apply()
          equ_src2= obj1.src
          equ_title2 = obj1.title
          equ_text1_2 = obj1.text1
          equ_text2_2 = obj1.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj1.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
        document.querySelector('.equipment .inbox2').addEventListener('click',function(){
          obj2.apply()
          equ_src2= obj2.src
          equ_title2 = obj2.title
          equ_text1_2 = obj2.text1
          equ_text2_2 = obj2.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj2.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
        document.querySelector('.equipment .inbox3').addEventListener('click',function(){
          obj3.apply()
          equ_src2= obj3.src
          equ_title2 = obj3.title
          equ_text1_2 = obj3.text1
          equ_text2_2 = obj3.text2
          ability_refresh()
          HPMP_refresh()
          packbag_refresh()
          word2(`装备 ${obj3.title} !`,50,"red",1500)
          document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
      }
  }
  //选择祝福函数
  function blessings(){
    
    const list = [...attribute_list]
    
      let random = Math.floor(Math.random()*list.length)
      let obj1 = list[random]
      list.splice(random,1)
      random = Math.floor(Math.random()*list.length)
      let obj2 = list[random]
      list.splice(random,1)
      random = Math.floor(Math.random()*list.length)
      let obj3 = list[random]
      list.splice(random,1)
    
      document.querySelector('.blessings .inbox').innerHTML=`
       <div class="inbox1">
          <img src="${obj1.src}" alt="">
          <div class="text1">${obj1.title}</div>
          <div class="text2">${obj1.text}</div>
        </div>
        <div class="inbox2">
          <img src="${obj2.src}" alt="">
          <div class="text1">${obj2.title}</div>
          <div class="text2">${obj2.text}</div>
        </div>
        <div class="inbox3">
          <img src="${obj3.src}" alt="">
          <div class="text1">${obj3.title}</div>
          <div class="text2">${obj3.text}</div>
        </div>
      `
    document.querySelector('.blessings').classList.toggle('show')
    document.querySelector('.blessings .inbox1').addEventListener('click',function(){
        obj1.apply()
        ability_refresh()
        word2(`${obj1.text}!`,50,"yellow",1500)
        document.querySelector('.blessings').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
      document.querySelector('.blessings .inbox2').addEventListener('click',function(){
        obj2.apply()
        ability_refresh()
        word2(`${obj2.text}!`,50,"yellow",1500)
        document.querySelector('.blessings').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
      document.querySelector('.blessings .inbox3').addEventListener('click',function(){
        obj3.apply()
        ability_refresh()
        word2(`${obj3.text}!`,50,"yellow",1500)
        document.querySelector('.blessings').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
  }
  //选择技能函数
  function skill(){
    let list = []
    if(character === '战士'){
      if(flag === 0){list = a_skill_list1}
      else if(flag === 1){list = a_skill_list2}
      else if(flag === 2){list = a_skill_list3}
    }
    else if(character === '射手'){
      if(flag === 0){list = b_skill_list1}
      else if(flag === 1){list = b_skill_list2}
      else if(flag === 2){list = b_skill_list3}
    }
    else if(character === '法师'){
      if(flag === 0){list = c_skill_list1}
      else if(flag === 1){list = c_skill_list2}
      else if(flag === 2){list = c_skill_list3}
    }
    let vir_list = list.slice()
    let random = Math.floor(Math.random()*vir_list.length)
    let obj1 = vir_list[random]
    vir_list.splice(random,1)
    random = Math.floor(Math.random()*vir_list.length)
    let obj2 = vir_list[random]
    vir_list.splice(random,1)
    random = Math.floor(Math.random()*vir_list.length)
    let obj3 = vir_list[random]
    vir_list.splice(random,1)
    
    document.querySelector('.skill .inbox').innerHTML=`
     <div class="inbox1">
        <div class="text1">${obj1.skill_title}</div>
        <div class="text2">●${obj1.skill_consume} 魔力值</div>
        <div class="text3">${obj1.skill_text}</div>
      </div>
      <div class="inbox2">
        <div class="text1">${obj2.skill_title}</div>
        <div class="text2">●${obj2.skill_consume} 魔力值</div>
        <div class="text3">${obj2.skill_text}</div>
      </div>
      <div class="inbox3">
        <div class="text1">${obj3.skill_title}</div>
        <div class="text2">●${obj3.skill_consume} 魔力值</div>
        <div class="text3">${obj3.skill_text}</div>
      </div>
      `
    document.querySelector('.skill').classList.toggle('show')
    document.querySelector('.skill .inbox1').addEventListener('click',function(){
        if(document.querySelector('.fight-skill').childElementCount<4){
          document.querySelector('.fight-skill').innerHTML+=`
          <div class="button-wrapper">
          <button class="fight-skills button-locked" data-id="${obj1.id}" data-skill_consume="${obj1.skill_consume}" data-skill_text="${obj1.skill_text}" data-skill_title="${obj1.skill_title}">${obj1.skill_title}</button>
          <div class="wrapper" data-id="${obj1.id}" data-skill_consume="${obj1.skill_consume}" data-skill_text="${obj1.skill_text}" data-skill_title="${obj1.skill_title}"></div>
          
        </div>
        `
        word2(`习得 ${obj1.skill_title} !`,35,"red",1500)
        document.querySelector('.skill').classList.toggle('show')
        let index = list.findIndex(item=>item.id === obj1.id)
        list.splice(index,1)
      document.querySelector('.walk').classList.remove('hide')
    }
        else alert('技能上限已满！请先删除至少一个技能！')
      })
      document.querySelector('.skill .inbox2').addEventListener('click',function(){
        if(document.querySelector('.fight-skill').childElementCount<4){
          document.querySelector('.fight-skill').innerHTML+=`
          <div class="button-wrapper">
          <button class="fight-skills button-locked" data-id="${obj2.id}" data-skill_consume="${obj2.skill_consume}" data-skill_text="${obj2.skill_text}" data-skill_title="${obj2.skill_title}">${obj2.skill_title}</button>
          <div class="wrapper" data-id="${obj2.id}" data-skill_consume="${obj2.skill_consume}" data-skill_text="${obj2.skill_text}" data-skill_title="${obj2.skill_title}"></div>
        </div>
        `
        word2(`习得 ${obj2.skill_title} !`,35,"red",1500)
        document.querySelector('.skill').classList.toggle('show')
        let index = list.findIndex(item=>item.id === obj2.id)
        list.splice(index,1)
      document.querySelector('.walk').classList.remove('hide')
    }
      else alert('技能上限已满！请先删除至少一个技能！')
      })
      document.querySelector('.skill .inbox3').addEventListener('click',function(){
        if(document.querySelector('.fight-skill').childElementCount<4){
          document.querySelector('.fight-skill').innerHTML+=`
          <div class="button-wrapper">
          <button class="fight-skills button-locked" data-id="${obj3.id}" data-skill_consume="${obj3.skill_consume}" data-skill_text="${obj3.skill_text}" data-skill_title="${obj3.skill_title}">${obj3.skill_title}</button>
          <div class="wrapper" data-id="${obj3.id}" data-skill_consume="${obj3.skill_consume}" data-skill_text="${obj3.skill_text}" data-skill_title="${obj3.skill_title}"></div>
        </div>
        `
        
        word2(`习得 ${obj3.skill_title} !`,35,"red",1500)
        document.querySelector('.skill').classList.toggle('show')
        let index = list.findIndex(item=>item.id === obj3.id)
        list.splice(index,1)
      document.querySelector('.walk').classList.remove('hide')
    }
      else alert('技能上限已满！请先删除至少一个技能！')
      })
  }
  //选择道具函数
  function prop(){
   
    let list = [...prop_list]
    let random = Math.floor(Math.random()*list.length)
    let obj1 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj2 = list[random]
    list.splice(random,1)
    random = Math.floor(Math.random()*list.length)
    let obj3 = list[random]
    list.splice(random,1)
    
    document.querySelector('.prop .inbox').innerHTML=`
     <div class="inbox1">
        <img src="${obj1.src}" alt="">
        <div class="text1">${obj1.title}</div>
        <div class="text2">${obj1.text}</div>
      </div>
      <div class="inbox2">
        <img src="${obj2.src}" alt="">
        <div class="text1">${obj2.title}</div>
        <div class="text2">${obj2.text}</div>
      </div>
      <div class="inbox3">
        <img src="${obj3.src}" alt="">
        <div class="text1">${obj3.title}</div>
        <div class="text2">${obj3.text}</div>
      </div>
      `
    document.querySelector('.prop').classList.toggle('show')
    document.querySelector('.prop .inbox1').addEventListener('click',function(){
        obj1.apply()
        pro_src= obj1.src
        pro_title = obj1.title
        pro_text = obj1.text
        pro_list+=`
        <div><img src=${pro_src} title="${pro_text}"></div>
        `
        ability_refresh()
        HPMP_refresh()
        packbag_refresh()
        word2(`获得 ${obj1.title} !`,35,"green",1500)
        document.querySelector('.prop').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
      document.querySelector('.prop .inbox2').addEventListener('click',function(){
        obj2.apply()
        pro_src= obj2.src
        pro_title = obj2.title
        pro_text = obj2.text
        pro_list+=`
        <div><img src=${pro_src} title="${pro_text}"></div>
        `
        ability_refresh()
        HPMP_refresh()
        packbag_refresh()
        word2(`获得 ${obj2.title} !`,35,"green",1500)
        document.querySelector('.prop').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
      document.querySelector('.prop .inbox3').addEventListener('click',function(){
        obj3.apply()
        pro_src= obj3.src
        pro_title = obj3.title
        pro_text = obj3.text
        pro_list+=`
        <div><img src=${pro_src} title="${pro_text}"></div>
        `
        ability_refresh()
        HPMP_refresh()
        packbag_refresh()
        word2(`获得 ${obj3.title} !`,35,"green",1500)
        document.querySelector('.prop').classList.toggle('show')
      document.querySelector('.event').style = 0
      document.querySelector('.walk').classList.remove('hide')
    })
  }
  //跳过功能
  (function(){
    
    document.querySelector('.weapon button').addEventListener('click',()=>{
      document.querySelector('.weapon').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.equipment button').addEventListener('click',()=>{
      document.querySelector('.equipment').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.blessings button').addEventListener('click',()=>{
      document.querySelector('.blessings').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.skill button').addEventListener('click',()=>{
      document.querySelector('.skill').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
    document.querySelector('.prop button').addEventListener('click',()=>{
      document.querySelector('.prop').classList.toggle('show')
      document.querySelector('.walk').classList.remove('hide')
    })
  })();
  //技能描述功能
  (function(){
    
    document.querySelector('.fight3').addEventListener('mouseover',e=>{
      if(e.target.className === 'wrapper'||e.target.className === 'fight-skills'){
       document.querySelector('.skills-text').innerHTML = `
       <span class="skill_title">${e.target.dataset.skill_title}</span>
       <span class="skill_consume">消耗 ${e.target.dataset.skill_consume} 点魔力</span>
       <span class="skill_text">${e.target.dataset.skill_text}</span>
       `
       document.querySelector('.skills-text').style.opacity = 1
      }
    })
    document.querySelector('.fight3').addEventListener('mouseout',e=>{
      if(e.target.className === 'wrapper'||e.target.className === 'fight-skills'){
       document.querySelector('.skills-text').style.opacity = 0
      }
    })

  })()
  //#endregion

//#region 战斗
//初始化临时加成
function temp_reflesh(){
  t_atk = 0
  t_spell_power = 0
  t_speed = 0
  t_crit_rate = 0
  t_crit_dmg = 0
  t_defense = 0
}
//刷新战斗数据函数
function fight_refresh(){
  HPMP_refresh()
  let mon_hp_bar = document.querySelector('.mon_hp_bar')
  mon_hp_bar.style.width = monHP*100/monMaxHP + '%'
  mon_hp_bar.innerHTML = monHP + '/' +monMaxHP
  document.querySelector('.potion').innerText = `使用血瓶(${potion_n}/${max_potion_n})`
  document.querySelector('.potion2').innerText = `使用魔瓶(${potion2_n}/${max_potion2_n})`
}
//刷新经验条
function updateEx() {
  if(ex>=300){
    ex%=300
    level++
    blessings()
    if(level % 3 === 0){
      skill()
    }
  }
  let experience_bar = document.querySelector('.experience-bar');
  document.querySelector('.ExperiencePoint').innerText = `等级: ${level}`
  document.querySelector('.coins').innerText = `金币: ${coins}`
  experience_bar.style.width = ex/3.0 + '%';
  experience_bar.innerText = ex + '/300';
}
//进入战斗函数（初始化怪物属性）
function in_fight(){
  ability_refresh()
  let list = []
  let obj
if(key){
  if(flag === 0){
    obj = boss_list[0]
  }
  else if(flag === 1){
    obj = boss_list[1]
  }
  else{
    obj = boss_list[2]
  }
}
else{
  if(flag === 0){list = [...mon_list1]}
  else if(flag === 1){list = [...mon_list2]}
  else if(flag === 2){list = [...mon_list2]}
  let random = Math.floor(Math.random()*list.length)
  obj = list[random]
}
  monMaxHP = obj.monHP
  monHP = obj.monHP
  monAtk = obj.monAtk
  monEx = obj.monEx
  monCoins = obj.monCoins
  document.querySelector('.monster').src = obj.src
  fight_refresh()
  word1('进入战斗！')
  my_turn()
  document.querySelector('.monster').style.opacity = 1
  document.querySelector('.mon').style.opacity = 1
}
//战斗结算函数
function out_fight(){
  word1('战斗结束！')
  document.querySelector('.walk').classList.remove('hide')
  document.querySelector('.turn').style.opacity = 0
  document.querySelector('.attack').classList.add('button-locked')
  document.querySelector('.potion').classList.add('button-locked')
  document.querySelector('.potion2').classList.add('button-locked')
  document.querySelector('.skills').classList.add('button-locked')
  document.querySelector('.fight-skills').classList.add('button-locked')
  document.querySelectorAll('.button-wrapper wrapper').forEach(e=>{
  e.classList.add('button-locked')
  })
  document.querySelector('.monster').style.opacity = 0
  document.querySelector('.mon').style.opacity = 0
  word1(` 获得${monEx} 点经验和 ${monCoins} 金币！`)
  if(potion_n<max_potion_n){
    potion_n++
  }
  ex+=monEx
  coins+=monCoins
  HP = maxHP
  MP = maxMP
  fight_refresh()
  updateEx(ex)
}
//进入随机事件函数
function reward(e){
  if(e>0.5&&e<1){
    word1('你发现了一个村庄')
    document.querySelector('.event').src = './img/祝福房子.png'
    document.querySelector('.event').style.opacity = 1
    setTimeout(()=>{
      blessings()
    },2500)
  }
  else if(e<=0.5){
    word1('你发现了一个道具袋')
    document.querySelector('.event').src = './img/道具袋.png'
    document.querySelector('.event').style.opacity = 1
    setTimeout(()=>{
      prop()
    },2500)
  }
  else if(e >= 1&&e<1.3){
    word1('你发现了一个武器箱')
    document.querySelector('.event').src = './img/武器箱子.png'
    document.querySelector('.event').style.opacity = 1
    setTimeout(()=>{
      weapon()
    },2500)
  }
  else if(e = 2){
    word1('成功打败第一个boss,获得装备奖励')
    setTimeout(()=>{
      equipment()
    },2500)
  }
  else if(e = 3){
    word1('成功打败第二个boss,获得装备奖励')
    setTimeout(()=>{
      equipment()
    },2500)
  }
}
// 我的回合函数
function my_turn(){
  temp_reflesh()
  ability_refresh()
  turn = '你的回合'
  document.querySelector('.turn').style.opacity = 1
  document.querySelector('.turn').innerText = '我的回合'
  document.querySelector('.turn').className = 'turn player-turn'
  document.querySelector('.attack').classList.remove('button-locked')
  document.querySelector('.potion').classList.remove('button-locked')
  document.querySelector('.potion2').classList.remove('button-locked')
  document.querySelector('.skills').classList.remove('button-locked')
}
// 怪物回合函数
function mon_turn(){
  turn = '敌人回合'
  document.querySelector('.turn').innerText = '敌人回合'
  document.querySelector('.turn').className = 'turn mon-turn'
  setTimeout(()=>{
    if(Math.random()>=(speed-90)/100){
      HP-=mon_damage()
      Hit('.player')
    }
      else{
        HP-=0
        word1('闪避攻击！')
      }
  if(HP>0){
    fight_refresh()
    setTimeout(()=>{
      word1('轮到你行动了！')
      my_turn()
    },2000)
  }
  else{
    HP = 0
    fight_refresh()
    setTimeout(()=>{
      word1('你输了！')
      document.querySelector('.screen').style.backgroundImage = 'url(./img/screenlose.jpeg);'
    },2000)
  }
  },2000)
}
//伤害计算公式
//战士普通攻击
//let player_damage1 = crit_rate*0.01 >= Math.random() ? atk * (1 + crit_dmg*0.01) * (1 + jingzhan*0.01) : atk * (1 + jingzhan*0.01)
//射手普通攻击
//let player_damage1 = crit_rate*0.01 >= Math.random() ? atk * (1 + crit_dmg*0.01) * (1 + yuancheng*0.01) : atk * (1 + yuansheng*0.01)
//法师普通攻击
// let player_damage1 = crit_rate*0.01 >= Math.random() ? spell_power * (1 + crit_dmg*0.01) * (1 + fashu*0.01) : spell_power * (1 + fashu*0.01)

//角色普通攻击伤害函数
function player_damage1(){
  ability_refresh()
  if (character === '战士'){
    if(crit_rate*0.01 >= Math.random()){
      let player_damage = Math.floor((atk + Math.random()*5) * (1 + crit_dmg*0.01) * (1 + jingzhan*0.01))
      word2('暴击！',15,'red',1500)
      word1(`敌人受到 ${player_damage} 点近战暴击伤害！`)
      return player_damage
  }
    else{
      let player_damage = Math.floor((atk + Math.random()*5) * (1 + jingzhan*0.01))
      word1(`敌人受到 ${player_damage} 点近战伤害！`)
      return player_damage
  }
  }
  if (character === '射手'){
    if(crit_rate*0.01 >= Math.random()){
      let player_damage = Math.floor((atk + Math.random()*5) * (1 + crit_dmg*0.01) * (1 + yuancheng*0.01))
      word1(`敌人受到 ${player_damage} 点暴击远程伤害！`)
      word2('暴击！',15,'red',1500)
      return player_damage
    }
    else{
      let player_damage = Math.floor((atk + Math.random()*5) * (1 + yuancheng*0.01))
      word1(`敌人受到 ${player_damage} 点远程伤害！`)
      return player_damage
    }
    }
  if(character === '法师'){
    
    let player_damage = Math.floor((spell_power + Math.random()*5) * (1 + fashu*0.01))
      word1(`敌人受到 ${player_damage} 点法术伤害！`)
      return player_damage
    
    }
}
//怪物伤害函数
function mon_damage(){
  if(Math.random() >= 0.75){
    let monster_damage = Math.floor(((monAtk + Math.random()*5) * 1.3) * (300 - defense)/300)
    word1(`受到 ${monster_damage} 点暴击伤害！`)
    return monster_damage
  }
  else{
  let monster_damage = Math.floor((monAtk + Math.random()*5) * (300 - defense)/300)
  word1(`受到 ${monster_damage} 点伤害！`)
  return monster_damage
}
}
//受击动画
function Hit(name) {
  if(name === '.player'){
    document.querySelector('.player').classList.add('playerhit')
    setTimeout(function() {
    document.querySelector('.player').classList.remove('playerhit')
  }, 500)
  }
  else{
    document.querySelector('.monster').classList.add('monhit')
    setTimeout(function() {
    document.querySelector('.monster').classList.remove('monhit')
  }, 500)
  }
}
//跑步动画
function Running() {
  document.querySelector('.player').classList.add('running')
  setTimeout(function() {
  document.querySelector('.player').classList.remove('running')
  }, 5000)
}
//tips刷新
setInterval(()=>{
  document.querySelector('.tips').innerText = "Tips：" +tips[Math.floor(Math.random()*tips.length)]
},15000)
//过一关函数
function barrieradd(){
  barrier++
  document.querySelector('.barrier').innerText = `第 ${barrier} 关`
}
//角色行动
//攻击
document.querySelector('.attack').addEventListener('click',()=>{
  document.querySelector('.attack').classList.add('button-locked')
  document.querySelector('.potion').classList.add('button-locked')
  document.querySelector('.potion2').classList.add('button-locked')
  document.querySelector('.skills').classList.add('button-locked')
  ability_refresh()
  monHP-=player_damage1()
  Hit('.monster')
  if(monHP>0){
    fight_refresh()
    setTimeout(()=>{
      MP+=10
      if(MP>maxMP){
        MP = maxMP
      }
      HPMP_refresh()
      word1('轮到敌人行动！')
      mon_turn()
    },2000)
  }
  else{
    monHP = 0
    fight_refresh()
    setTimeout(()=>{
      word1('你赢了！')
      setTimeout(()=>{
        out_fight()
      },1700)
    },2000)
  }
})
//血瓶
document.querySelector('.potion').addEventListener('click',()=>{
  if(potion_n >= 1){
  document.querySelector('.attack').classList.add('button-locked')
  document.querySelector('.potion').classList.add('button-locked')
  document.querySelector('.potion2').classList.add('button-locked')
  document.querySelector('.skills').classList.add('button-locked')
  potion_n--
  HP+= potion_v
  if(HP/maxHP>1)
  {
    HP = maxHP
  }
  word1(`HP + ${potion_v}`) 
  fight_refresh()
  setTimeout(()=>{
    word1('轮到敌人行动！')
    mon_turn()
  },2000)
  }
  else{
    word1('你已经没血瓶喝了！')
  }
})
//魔瓶
document.querySelector('.potion2').addEventListener('click',()=>{
  if(potion2_n >= 1){
  document.querySelector('.attack').classList.add('button-locked')
  document.querySelector('.potion').classList.add('button-locked')
  document.querySelector('.potion2').classList.add('button-locked')
  document.querySelector('.skills').classList.add('button-locked')
  potion2_n--
  MP+= potion2_v
  if(MP/maxMP>1)
  {
    MP = maxMP
  }
  word1(`MP + ${potion2_v}`) 
  fight_refresh()
  setTimeout(()=>{
    word1('轮到敌人行动！')
    mon_turn()
  },2000)
  }
  else{
    word1('你已经没魔瓶喝了！')
  }
})
//技能
document.querySelector('.skills').addEventListener('click',()=>{
  document.querySelector('.attack').classList.toggle('button-locked')
  document.querySelector('.potion').classList.toggle('button-locked')
  document.querySelector('.potion2').classList.toggle('button-locked')
  document.querySelectorAll('.fight-skills').forEach(e=>{
    e.classList.toggle('button-locked')
  })
})
//技能
document.querySelector('.fight3').addEventListener('click',e=>{
  if(e.target.tagName === 'BUTTON'){
    document.querySelectorAll('.fight-skills').forEach(ele=>{
      ele.classList.toggle('button-locked')
    })
    document.querySelector('.skills').classList.add('button-locked')
    ability_refresh()

    let id = e.target.dataset.id
    
    if(MP>=e.target.dataset.skill_consume){
      if(id === '0'){
        console.log(666);
        MP-=25;t_crit_rate=10;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 1.3*atk*(1+jingzhan*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击近战伤害！`)
        }
        else{
          player_damage2 = 1.3*atk*(1+jingzhan*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点近战伤害！`)
        }}
      else if(id === '1'){MP-=25;player_damage2 = 1.2*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '2'){MP-=25;player_damage2 = 1.2*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '3'){MP-=25;player_damage2 = 1.2*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '4'){MP-=20;player_damage2 = atk;HP+=20;word1(`敌人受到 ${Math.floor(player_damage2)} 点物理伤害！`)}
      else if(id === '5'){MP-=10;t_defense = 30;ability_refresh();player_damage2 = 1.5*defense;word1(`敌人受到 ${Math.floor(player_damage2)} 点防御力伤害！`)}
  
      else if(id === '6'){
        MP-=25;t_crit_rate=25;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 1.5*atk*(1+jingzhan*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击近战伤害！`)
        }
        else{
          player_damage2 = 1.5*atk*(1+jingzhan*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点近战伤害！`)
        }
      }
      else if(id === '7'){MP-=30;player_damage2 = 1.4*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '8'){MP-=30;player_damage2 = 1.4*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '9'){MP-=30;player_damage2 = 1.4*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '10'){MP-=25;player_damage2 = 1.2*atk;HP+=30;word1(`敌人受到 ${Math.floor(player_damage2)} 点物理伤害！`)}
      else if(id === '11'){MP-=15;t_defense = 50;ability_refresh();player_damage2 = 2*defense;word1(`敌人受到 ${Math.floor(player_damage2)} 点防御力伤害！`)}
      
      else if(id === '12'){
        MP-=35;t_crit_rate=40;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 2*atk*(1+jingzhan*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击近战伤害！`)
        }
        else{
          player_damage2 = 2*atk*(1+jingzhan*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点近战伤害！`)
        }
      }
      else if(id === '13'){MP-=35;player_damage2 = 1.8*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '14'){MP-=35;player_damage2 = 1.8*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '15'){MP-=35;player_damage2 = 1.8*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '16'){MP-=30;player_damage2 = 1.4*atk;HP+=50;word1(`敌人受到 ${Math.floor(player_damage2)} 点物理伤害！`)}
      else if(id === '17'){MP-=20;t_defense = 100;ability_refresh();player_damage2 = 2.5*defense;word1(`敌人受到 ${Math.floor(player_damage2)} 点防御力伤害！`)}
  
      else if(id === '18'){
        MP-=25;t_crit_dmg=20;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 1.3*atk*(1+yuancheng*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击远程伤害！`)
        }
        else{
          player_damage2 = 1.3*atk*(1+yuancheng*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)
        }
      }
      else if(id === '19'){MP-=25;player_damage2 = 1.2*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '20'){MP-=25;player_damage2 = 1.2*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '21'){MP-=25;player_damage2 = 1.2*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '22'){MP-=20;player_damage2 = atk*(1+yuancheng*0.01);t_speed=25;ability_refresh();word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)}
  
      else if(id === '23'){
        MP-=30;t_crit_dmg=50;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 1.5*atk*(1+yuancheng*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击远程伤害！`)
        }
        else{
          player_damage2 = 1.5*atk*(1+yuancheng*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)
        }
      }
      else if(id === '24'){MP-=30;player_damage2 = 1.4*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '25'){MP-=30;player_damage2 = 1.4*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '26'){MP-=30;player_damage2 = 1.4*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '27'){MP-=25;player_damage2 = 1.2*atk*(1+yuancheng*0.01);t_speed=35;ability_refresh();word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)}
  
      else if(id === '28'){
        MP-=35;t_crit_dmg=80;ability_refresh();
        if(crit_rate*0.01 >= Math.random()){
          player_damage2 = 2*atk*(1+yuancheng*0.01)*(1+crit_dmg*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点暴击远程伤害！`)
        }
        else{
          player_damage2 = 2*atk*(1+yuancheng*0.01);
          word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)
        }
      }
      else if(id === '29'){MP-=25;player_damage2 = 1.8*atk*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性物理伤害！`)}
      else if(id === '30'){MP-=25;player_damage2 = 1.8*atk*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性物理伤害！`)}
      else if(id === '31'){MP-=25;player_damage2 = 1.8*atk*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性物理伤害！`)}
      else if(id === '32'){MP-=20;player_damage2 = 1.4*atk*(1+yuancheng*0.01);t_speed=45;ability_refresh();word1(`敌人受到 ${Math.floor(player_damage2)} 点远程伤害！`)}
  
      else if(id === '33'){MP-=10;t_defense = 50;player_damage2 = 0;ability_refresh();MP+=30}
      else if(id === '34'){MP-=30;player_damage2 = 1.3*spell_power*(1+fashu*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点法术伤害！`)}
      else if(id === '35'){MP-=30;player_damage2 = 1.2*spell_power*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性法术伤害！`)}
      else if(id === '36'){MP-=30;player_damage2 = 1.2*spell_power*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性法术伤害！`)}
      else if(id === '37'){MP-=30;player_damage2 = 1.2*spell_power*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性法术伤害！`)}
      
      else if(id === '38'){MP-=10;t_defense = 80;player_damage2 = 0;ability_refresh();MP+=40}
      else if(id === '39'){MP-=35;player_damage2 = 1.6*spell_power*(1+fashu*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点法术伤害！`)}
      else if(id === '40'){MP-=35;player_damage2 = 1.5*spell_power*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性法术伤害！`)}
      else if(id === '41'){MP-=35;player_damage2 = 1.5*spell_power*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性法术伤害！`)}
      else if(id === '42'){MP-=35;player_damage2 = 1.5*spell_power*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性法术伤害！`)}
      
      else if(id === '43'){MP-=10;t_defense = 120;player_damage2 = 0;ability_refresh();MP+=50}
      else if(id === '44'){MP-=40;player_damage2 = 2*spell_power*(1+fashu*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点法术伤害！`)}
      else if(id === '45'){MP-=40;player_damage2 = 2*spell_power*(1+fire*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点火属性法术伤害！`)}
      else if(id === '46'){MP-=40;player_damage2 = 2*spell_power*(1+water*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点水属性法术伤害！`)}
      else if(id === '47'){MP-=40;player_damage2 = 2*spell_power*(1+wind*0.01);word1(`敌人受到 ${Math.floor(player_damage2)} 点风属性法术伤害！`)}
      
      fight_refresh()
      monHP-=Math.floor(player_damage2)
      Hit('.monster')
    if(monHP>0){
      fight_refresh()
      setTimeout(()=>{
        word1('轮到敌人行动！')
        mon_turn()
      },2000)
    }
    else{
      monHP = 0
      fight_refresh()
      setTimeout(()=>{
        word1('你赢了！')
        setTimeout(()=>{
          out_fight()
        },1700)
      },2000)
    }
  
    }
    else{
      alert('魔力值不足！')
      document.querySelectorAll('.fight-skills').forEach(ele=>{
        ele.classList.toggle('button-locked')
      })
      document.querySelector('.skills').classList.remove('button-locked')
    }
  }
})
//#endregion

//删除技能函数
document.querySelector('.delete-button').addEventListener('click',()=>{
  document.querySelector('.delete2').classList.toggle('hide')
})
document.querySelector('.submit').addEventListener('click',()=>{
  let delete_index = document.querySelector('.number').value
  let delete_skill = document.querySelectorAll(`.fight-skill .button-wrapper`)[delete_index]
  if(delete_skill){
  delete_skill.parentNode.removeChild(delete_skill)
  }
})
  function mid_barrier(){//设定中期
    flag = 1
    max_potion_n = 2
    MP+=20
    maxMP+=20
    packbag_refresh()
  }
  function bto_barrier(){//设定后期
    flag = 2
    max_potion_n = 3
    MP+=25
    maxMP+=25
    packbag_refresh()
  }
  document.querySelector('.start').addEventListener('click',function(){//开始游戏
    document.querySelector('.start').style.display = 'none'
    document.querySelectorAll('.move').forEach(e=>{
      e.style.opacity = 1
    })
    document.querySelector('.player').style.opacity = 1
    document.querySelector('.walk').classList.remove('hide')
    document.querySelector('.screen').style.backgroundImage = 'url(./img/screen1.jpeg)'
    document.querySelectorAll('.move').forEach(e=>{
      e.style.animationPlayState = 'paused';
    })
  })
  document.querySelector('.walk').addEventListener('click',function(){//移动
    document.querySelector('.walk').classList.add('hide')
    Running()
    document.querySelectorAll('.move').forEach(e=>{
    e.style.animationPlayState = 'running';
    })
    setTimeout(function(){
    document.querySelectorAll('.move').forEach(e=>{
    e.style.animationPlayState = 'paused';
  })
//
  let ran_reward
  if(flag === 0){
    ran_reward = Math.random()
  }
  else {ran_reward = Math.random()*1.3}
//
  if(barrier === 0){
    barrieradd()
    role()
  }
  else if(barrier === 7 ){
    barrieradd()
    key = true
    in_fight()
    key = false
  }
  else if(barrier === 8){
    barrieradd()
    mid_barrier()
    reward(2)
  }
  else if(barrier === 14 ){
    barrieradd()
    key = true
    in_fight()
    key = false
  }
  else if(barrier === 15){
    barrieradd()
    bto_barrier()
    reward(3)
  }
  else if(barrier === 21 ){
    barrieradd()
    key = true
    in_fight()
    key = false
  }
  else if(barrier === 22){
    document.querySelector('.screen').style.backgroundImage = 'url(./img/screenwin.jpeg);'
  }
  else{
    if(Math.random()>=0.45){
      barrieradd()
      in_fight()
    }
    else{
      barrieradd()
      reward(ran_reward)
    }
  }
    },5000)
  })




